package user;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @classname:UserTest
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/1 21:18
 * @version: 0.1
 * @since:1.8
 */
public class UserTest {
    public static void main(String[] args) {
        //初始化四个权限对象
        Scanner input = new Scanner(System.in);
        Permission[] permissions = new Permission[4];
        for (int i = 1; i < 5; i++) {
            System.out.println("请输入权限地址");
            String url = input.next();
            System.out.println("请输入权限说明");
            String remark = input.next();
            permissions[i - 1] = new Permission(i, url, remark);
        }
        //初始化两个角色
        Role[] roles = new Role[2];
        Role role0 = new Role(1001, "管理员");

        role0.permissions = new Permission[]{permissions[0], permissions[1], permissions[2]};
        Role role1 = new Role(1002, "超级管理员");

        role1.permissions = permissions;
        roles[0] = role0;
        roles[1] = role1;

        System.out.println(Arrays.toString(permissions));
        User user = new User(1, "admin");
        user.role = new Role(1002, "管理员");

        for (Role role : roles) {
            if (role.id == user.role.id) {
                for (Permission permission : role.permissions) {
                    System.out.println("权限" + permission.url + "," + permission.remark);
                }

            }

        }

    }

}
